﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace HAILN_Y2016CS32ONLINE.Structure_Program.Exer
{
    public partial class Form3 : Form
    {
        int i = 0;
        public Form3()
        {
            InitializeComponent();
        }

        private void btndangky_Click(object sender, EventArgs e)
        {
            errorProvider1.Clear();
            txtKetqua.Clear();

            if (string.IsNullOrEmpty(txtTen.Text)) errorProvider1.SetError(txtTen, "ban hay nhap ten");
            else if (string.IsNullOrEmpty(txtTuoi.Text)) errorProvider1.SetError(txtTuoi, "ban hay nhaptuoi");
            else if (string.IsNullOrEmpty(cboGioiTinh.Text)) errorProvider1.SetError(cboGioiTinh, "hay chon gioi tinh");
            else if (string.IsNullOrEmpty(cboTTHN.Text)) errorProvider1.SetError(cboTTHN, "hay chon tinh trang hon nhan");
            else if (!int.TryParse(txtTuoi.Text, out i)) ;  
            else
            {
                if (!int.TryParse(txtTuoi.Text, out i)) { errorProvider1.SetError(txtTuoi, "hay nhap lai"); }
                if ((int.Parse(txtTuoi.Text) >= 22) && (cboTTHN.Text.Equals("Chưa Kết Hôn")) && (cboGioiTinh.Text.Equals("Nam")))
                {
                    txtKetqua.Text = "Duoc phep tham gia";
                }
                else if ((i >= 19) && (cboTTHN.Text.Equals("Chưa Kết Hôn")) && (cboGioiTinh.Text.Equals("Nữ")))
                {
                    txtKetqua.Text = "Duoc phep tham gia";
                }
                else txtKetqua.Text = "Khong duoc tham gia";

            }
        }

        private void Form3_Load(object sender, EventArgs e)
        {

        }
    }
}
